let obj = {
    code: 1,
    user: 2,
    code2: 2,
}

if ('code4' in obj) {
    console.log(obj['code'])
} else {
    console.log(obj)
}